package com.baoyouqun.service;

import com.alibaba.cola.dto.Response;
import com.alibaba.cola.dto.SingleResponse;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baoyouqun.domain.CreateCmd.UserSearchRecordCreateCmd;
import com.baoyouqun.domain.Query.UserSearchRecordPageQuery;
import com.baoyouqun.domain.Query.UserSearchRecordQuery;
import com.baoyouqun.domain.UpdateCmd.UserSearchRecordUpdateCmd;
import com.baoyouqun.domain.VO.KeywordFrequencyVO;
import com.baoyouqun.domain.VO.UserSearchRecordVO;
import com.baoyouqun.entity.UserSearchRecord;
import jakarta.servlet.http.HttpServletResponse;

import java.util.List;

public interface UserSearchRecordService extends IService<UserSearchRecord> {
    /**
     * 创建搜索记录
     */
    SingleResponse<UserSearchRecordVO> create(UserSearchRecordCreateCmd cmd);

    /**
     * 更新搜索记录
     */
    Response update(UserSearchRecordUpdateCmd cmd);

    /**
     * 根据ID查询搜索记录
     */
    UserSearchRecordVO selectById(String id);

    /**
     * 基础分页查询（旧逻辑，保留兼容）
     */
    IPage<UserSearchRecordVO> pageVo(UserSearchRecordQuery query);

    /**
     * 按条件查询关键词关联的用户记录（分页，新逻辑）
     */
    SingleResponse<IPage<UserSearchRecordVO>> pageUserByKeyword(UserSearchRecordPageQuery query);

    /**
     * 导出用户搜索记录Excel
     */
    void exportUserSearchRecords(UserSearchRecordPageQuery query, HttpServletResponse response);

    /**
     * 获取高频关键词（分页）
     */
    IPage<KeywordFrequencyVO> getHighFrequencyKeywords(Long pageSize, Long current, String keyword, Boolean isAsc);

    // 获取目标用户的搜索记录关键词
    List<String> selectLatestKeywordsByUserId(String id, int i);
}